using System;
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;

namespace LS
{
    [Serializable]
    public class DataTableFileInfo
    {
        [SerializeField]
        private string m_Name;

        [SerializeField]
        private string m_Extension;

        [SerializeField]
        private string m_FilePath;

#if UNITY_EDITOR
        [SerializeField]
        private bool m_EnableGenerate;

        [SerializeField]
        private string m_GUID;
#endif
        /// <summary>
        /// 配置表名称，无法在运行时赋值
        /// </summary>
        public string Name
        {
            get => m_Name;
            set
            {
#if UNITY_EDITOR
                if(!Application.isPlaying)
                    m_Name = value;
#endif
            }
        }

        /// <summary>
        /// 文件拓展名
        /// </summary>
        public string Extension
        {
            get => m_Extension;
            set
            {
#if UNITY_EDITOR
                if (!Application.isPlaying)
                    m_Extension = value;
#endif
            }
        }

        /// <summary>
        /// 文件路径
        /// </summary>
        public string FilePath
        {
            get => m_FilePath;
            set
            {
#if UNITY_EDITOR
                if (!Application.isPlaying)
                    m_FilePath = value;
#endif
            }
        }

#if UNITY_EDITOR
        /// <summary>
        /// 是否启用代码生成
        /// </summary>
        public bool EnableGenerate
        {
            get => m_EnableGenerate;
            set => m_EnableGenerate = value;
        }

        /// <summary>
        /// 资源guid
        /// </summary>
        public string AssetGuid
        {
            get => m_GUID;
            set => m_GUID = value;
        }
#endif

        
        public override bool Equals(object obj)
        {
            return obj is DataTableFileInfo &&
#if UNITY_EDITOR
                m_GUID == ((DataTableFileInfo)obj).m_GUID
#else
                ((DataTableFileInfo)obj).m_FilePath == this.m_FilePath
#endif
                ;
        }

        public override int GetHashCode()
        {
#if UNITY_EDITOR
            return this.m_GUID.GetHashCode();
#else
            return this.m_FilePath.GetHashCode();
#endif
        }
    }
}
